package br.com.orion.sga.model.dao;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.orion.sga.model.entities.Empresa;

@Transactional
@Repository("empresaDao")
public class EmpresaDao extends GenericDao<Empresa, Long>{
	
	
	/**
	 * getCompanyByName
	 * @param city
	 * @return
	 */
	public Empresa getCompanyByName(String company){
		
		String sql = "from Empresa e WHERE upper(e.razaoSocial) = :company";
		Query query = entityManager.createQuery(sql);
		query.setParameter("company", company);
		
		return (Empresa) query.getSingleResult();
	}

}
